#ifndef COUNTER_H
#define COUNTER_H
#include <vector>
using namespace std;

// A class that counts up based on a vector
class Counter {
  private:
    // The vector that determines the counting range
    vector<uint32_t> range;
    // The current value of the counter
    vector<uint32_t> value;
  public:
    // Constructor that takes a vector as input
    Counter(vector<uint32_t> range) {
      this->range = range;
      // Initialize the value to all zeros
      value.resize(range.size(), 0);
    }
    // A method that increments the counter by one
    void increment() {
      // Start from the rightmost digit
      int i = value.size() - 1;
      // Loop until there is no carry or we reach the leftmost digit
      while (i >= 0) {
        // Increment the current digit by one
        value[i]++;
        // If the current digit is equal to the range, reset it to zero and carry one to the left
        if (value[i] == range[i]) {
          value[i] = 0;
          i--;
        }
        // Otherwise, stop the loop
        else {
          break;
        }
      }
    }
    // A method that returns the current value of the counter as a vector
    vector<uint32_t> get_value() {
      return value;
    }
};
#endif // COUNTER_H
